home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20020314-20021006
/
000024_fdc@columbia.edu_Fri Apr 5 17:07:38 EST 2002.msg
< prev
next >
Wrap
Text File
|
2002-10-06
|
3KB
|
102 lines
Article: 13295 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
From: fdc@columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: How to get return code from external Unix box running simple shell script?
Date: 5 Apr 2002 17:07:26 -0500
Organization: Columbia University
Lines: 85
Message-ID: <a8l76u$j5e$1@watsol.cc.columbia.edu>
References: <d6e12cad.0204051329.574003a2@posting.google.com>
NNTP-Posting-Host: watsol.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1018044447 17555 128.59.39.139 (5 Apr 2002 22:07:27 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 5 Apr 2002 22:07:27 GMT
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13295
In article <d6e12cad.0204051329.574003a2@posting.google.com>,
Entfred <entfred@hotmail.com> wrote:
: I saw an old post that Frank da Cruz said about using IF SUCCESS or
: IF FAILURE to test the success or failure reported by an external command.
:
: What I want to do is something a little different:
:
: 1. Kermit script (on a Windows 2000 PC) telnets to an external Sun
: Unix box. The Kermit script is in a file called test.ksc:
:
: set term type at386
:
: set network tcp/ip
: set host test.machine.com
: output \13
: input 5 login:
: output testuser\13
: input 5 password:
: output testpassword\13
: input 5 $
: output testscript\13
: connect
: if fail (I am not sure what do do right here to get Unix return code)
: Exit
: End ;
:
: 2. On the Unix box, a simple script is run:
: (call the script, testscript)
:
: echo This is a test
: date
: exit 9
:
: 3. I would like the result code of 9 to be sent back to the kermit
: script residing on the Windows 2000 PC.
:
: How would this be done? Any tips to doing this would be
: appreciated!
:
You would use Kermit's client/server features, something like this:
; Part 1: Make connection, authenticate, start Kermit server
set network tcp/ip
set host test.machine.com
if fail exit 1 Can't reach host
set exit warning off
lineout
input 5 login:
if fail exit 1 No login prompt
lineout testuser
input 5 password:
if fail exit 1 No password prompt
lineout testpassword
input 5 $
if fail exit 1 No shell prompt
lineout kermit -x
input 5 KERMIT READY TO SERVE...
if fail echo WARNING: missing server message - continuing...
; Part 2: The real work
remote host testscript
query kermit pexitstat
echo testscript return code = \v(query)
bye
End ;
Notes:
1. Always remember to test critical commands for failure.
2. "lineout blah" is equivalent to "output blah\13", but better,
since it adjusts the line terminator according to the connection type.
3. \v(pexitstat) is the Kermit built-in variable that contains the exit
status code of the most recently invoked inferior process.
4. Part 1 is a lot easier and less reliant on changeable prompts
and strings if a Kermit server is already there waiting for you,
as would be the case with an Internet Kermit Service:
http://www.columbia.edu/kermit/cuiksd.html
- Frank